﻿using System;
using System.Windows;
using PureMVC.Interfaces;
using GameEngine.Model.Data;
using System.Collections.Generic;
using GameEngine.Libs;

namespace GameEngine.Model
{
    public interface IThingDataProxy<IdType> : IDataProxy
        where IdType : IComparable<IdType>
    {
        IWorldVOId WorldId{get; set;}
        IThingVO<IdType> VO { get; }

        Point Position { get; set; }
        Point MapPosition { get; set; }
        /// <summary>
        /// Relative, north = y=1, x=0
        /// </summary>
        Point Direction { get; set; }

        //string Type { get; }
        IThingVOId<IdType> Id { get; }

        IThingTypeVOId TypeId { get; }

        IViewStateVO State { get; }

        bool MovingWithMouse { get; set; }

        /// <summary>
        /// Change the state according to properties
        /// </summary>
        void UpdateState();

        //void Tick();
        IThingDataProxy<IdType> Replicate();
    }
    public class IThingDataProxyConstants<IdType>
        where IdType : IComparable<IdType>
    {
        public const string THINGCHANGED_NOTIFICATION = "ThingDataProxyChanged";
        public const string THINGCHANGEDHEIGHT_NOTIFICATIONTYPE = "ThingDataProxyHeightChanged";
        //public const string MAPPOSITIONCHANGED_NOTIFICATIONTYPE = "DataProxyMapPositionChanged";
        public const string THINGCHANGEDPOSITION_NOTIFICATIONTYPE = "ThingDataProxyPositionChanged";
        public const string THINGCHANGEDSTATE_NOTIFICATIONTYPE = "ThingDataProxyStateChanged";
        //public const string THINGCHANGEDDIRECTION_NOTIFICATIONTYPE = "ThingDataProxyDirectionChanged";
        static public string CreateName(IThingVOId<IdType> id)
        {
            return /*item.TypeId.Value + "_" +*/ "ThingDataProxy_" + id.Value;
        }

        static public string CreateName(IThingVO<IdType> item)
        {
            return CreateName(item.Id);
        }
    }
    
    public interface ISensingThingDataProxy<IdType> : IThingDataProxy<IdType>, IProxy
        where IdType : IComparable<IdType>
    {
        /// <summary>
        /// To be calculated in every sensibility time interval
        /// </summary>
        IDictionary<string, List<KeyValuePair<IThingVOId<IdType>, Point>>> ThingsInReach { get; }
        /// <summary>
        /// To be setted when direction is changed
        /// </summary>
        //IDictionary<string, List<Point>> InReachMapPositionsTransformed { get; set; }

    }

    public interface IMovingThingDataProxy<ItemVOId> : ISensingThingDataProxy<ItemVOId>, IProxy
        where ItemVOId : IComparable<ItemVOId>
    {
        bool Moving{get;}
        Point? Destination { get; set; }
    }

    public interface IThinkingThingDataProxy<ItemVOId> : IMovingThingDataProxy<ItemVOId>, IProxy
         where ItemVOId : IComparable<ItemVOId>
    {
        NeuralNetwork Brain { get; set; }  
        
    }

    //controlled thing
}